<?php

namespace App\Http\Requests\Home;

use Illuminate\Foundation\Http\FormRequest;

class UserAddress extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    { 
        return [
            'link_man'  => 'required',
            'code'     => 'required',
            'phone'     =>[
                'required',
                'regex:/^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$/',
            ],
            'address'   => 'required'
            'state'       => 'required'
        ];
    }

    public function messages()
    {
         return [
            'link_man.required'  => '请输入收货人',

            'phone.required'   => '请输入手机号码',
            'phone.regex'      => '手机号不合法',

            'code.required'     => '邮编不能为空',

            'address.required' => '地址不能为空',
            'state'            => '请选择状态',
        ];
    }
}
